<!DOCTYPE html>
<html itemscope="" itemtype="http://schema.org/QAPage"><head>
<meta http-equiv="content-type" content="text/html; charset=UTF-8">
    
    <title>Implementing a customized drawable in Android - Stack Overflow</title>
    <link rel="shortcut icon" href="http://cdn.sstatic.net/stackoverflow/img/favicon.ico?v=6cd6089ee7f6">
    <link rel="apple-touch-icon image_src" href="http://cdn.sstatic.net/stackoverflow/img/apple-touch-icon.png?v=41f6e13ade69">
    <link rel="search" type="application/opensearchdescription+xml" title="Stack Overflow" href="http://stackoverflow.com/opensearch.xml">
    <meta name="twitter:card" content="summary">
    <meta name="twitter:domain" content="stackoverflow.com">
    <meta property="og:type" content="website">
    <meta property="og:image" itemprop="image primaryImageOfPage" content="http://cdn.sstatic.net/stackoverflow/img/apple-touch-icon@2.png?v=ea71a5211a91">
    <meta name="twitter:title" property="og:title" itemprop="title name" content="Implementing a customized drawable in Android">
    <meta name="twitter:description" property="og:description" itemprop="description" content="I was trying to get hold of 2D graphics in Android.
  As a example i want to implement a custom drawable and show it in my Activity

I have defined a customized drawable by extending from Android ">
    <meta property="og:url" content="http://stackoverflow.com/questions/2967904/implementing-a-customized-drawable-in-android">
    <link rel="canonical" href="http://stackoverflow.com/questions/2967904/implementing-a-customized-drawable-in-android">

    
    
    <script src="Implementing%20a%20customized%20drawable%20in%20Android_files/ados" async="" type="text/javascript"></script><script src="Implementing%20a%20customized%20drawable%20in%20Android_files/quant.js" async=""></script><script src="Implementing%20a%20customized%20drawable%20in%20Android_files/beacon.js" async=""></script><script src="Implementing%20a%20customized%20drawable%20in%20Android_files/analytics.js" async=""></script><script src="Implementing%20a%20customized%20drawable%20in%20Android_files/ados.js" async="" type="text/javascript"></script><script src="Implementing%20a%20customized%20drawable%20in%20Android_files/jquery.js"></script>
    <script src="Implementing%20a%20customized%20drawable%20in%20Android_files/stub.js"></script>
    <link rel="stylesheet" type="text/css" href="Implementing%20a%20customized%20drawable%20in%20Android_files/all.css">
    
    <link rel="alternate" type="application/atom+xml" title="Feed for question 'Implementing a customized drawable in Android'" href="http://stackoverflow.com/feeds/question/2967904">
    <meta name="twitter:app:country" content="US">
    <meta name="twitter:app:name:iphone" content="Stack Exchange iOS">
    <meta name="twitter:app:id:iphone" content="871299723">
    <meta name="twitter:app:url:iphone" content="se-zaphod://stackoverflow.com/questions/2967904/implementing-a-customized-drawable-in-android">
    <meta name="twitter:app:name:ipad" content="Stack Exchange iOS">
    <meta name="twitter:app:id:ipad" content="871299723">
    <meta name="twitter:app:url:ipad" content="se-zaphod://stackoverflow.com/questions/2967904/implementing-a-customized-drawable-in-android">
    <meta name="twitter:app:name:googleplay" content="Stack Exchange Android">
    <meta name="twitter:app:url:googleplay" content="http://stackoverflow.com/questions/2967904/implementing-a-customized-drawable-in-android">
    <meta name="twitter:app:id:googleplay" content="com.stackexchange.marvin">
    <script>
        
        StackExchange.ready(function () {
                
                StackExchange.using("snippets", function () {
                    StackExchange.snippets.initSnippetRenderer();
                });
                

            StackExchange.using("postValidation", function () {
                StackExchange.postValidation.initOnBlurAndSubmit($('#post-form'), 2, 'answer');
            });

            
            StackExchange.question.init({showAnswerHelp:true,totalCommentCount:0,shownCommentCount:0,highlightColor:'#F4A83D',backgroundColor:'#FFF',questionId:2967904});

            styleCode();

                StackExchange.realtime.subscribeToQuestion('1', '2967904');
                                    
        });
    </script>


    <script>
        StackExchange.init({"locale":"en","stackAuthUrl":"https://stackauth.com","serverTime":1426174377,"networkMetaHostname":"meta.stackexchange.com","routeName":"Questions/Show","styleCode":true,"enableUserHovercards":true,"snippets":{"enabled":true,"domain":"stacksnippets.net"},"site":{"name":"Stack Overflow","description":"Q&A for professional and enthusiast programmers","isNoticesTabEnabled":true,"recaptchaPublicKey":"6LdchgIAAAAAAJwGpIzRQSOFaO0pU6s44Xt8aTwc","recaptchaAudioLang":"en","enableNewTagCreationWarning":true,"insertSpaceAfterNameTabCompletion":false,"nonAsciiTags":true,"enableSocialMediaInSharePopup":true},"user":{"fkey":"7d79d500f57d16c8348b0cafce12f3e4","isAnonymous":true}});
        StackExchange.using.setCacheBreakers({"js/prettify-full.en.js":"b175eb924d57","js/moderator.en.js":"9be321ee4fdc","js/full-anon.en.js":"6db2cae40593","js/full.en.js":"8d494d746c62","js/wmd.en.js":"e3cea4ddb176","js/third-party/jquery.autocomplete.min.js":"e5f01e97f7c3","js/third-party/jquery.autocomplete.min.en.js":"","js/mobile.en.js":"0c842be285f8","js/help.en.js":"1ad0e1555080","js/tageditor.en.js":"cce06892ec76","js/tageditornew.en.js":"826ad849aac1","js/inline-tag-editing.en.js":"1498d8619942","js/revisions.en.js":"989c474e85a9","js/review.en.js":"bfd78f82de6e","js/tagsuggestions.en.js":"b278f9a0b23b","js/post-validation.en.js":"5f888917f392","js/explore-qlist.en.js":"257ba4cb7b04","js/events.en.js":"2fa54a1ec36c","js/keyboard-shortcuts.en.js":"a6f850dce3f7","js/external-editor.en.js":"a9a74e04c9b0","js/external-editor.en.js":"a9a74e04c9b0","js/snippet-javascript.en.js":"7700e8b17c10","js/snippet-javascript-codemirror.en.js":"9275259d10ab"});
        StackExchange.using("gps", function() {
             StackExchange.gps.init(true);
        });
    </script>
    
        <script>
            StackExchange.ready(function () {
                $('#nav-tour').click(function () {
                    StackExchange.using("gps", function() {
                        StackExchange.gps.track("aboutpage.click", { aboutclick_location: "headermain" }, true);
                    });
                });
            });
        </script>
    
    
<script src="Implementing%20a%20customized%20drawable%20in%20Android_files/full-anon.js" async=""></script><script src="Implementing%20a%20customized%20drawable%20in%20Android_files/snippet-javascript.js" async=""></script><script src="Implementing%20a%20customized%20drawable%20in%20Android_files/post-validation.js" async=""></script><script src="Implementing%20a%20customized%20drawable%20in%20Android_files/prettify-full.js" async=""></script><script src="Implementing%20a%20customized%20drawable%20in%20Android_files/external-editor.js" async=""></script><script src="Implementing%20a%20customized%20drawable%20in%20Android_files/adFeedback.js" type="text/javascript"></script><link href="Implementing%20a%20customized%20drawable%20in%20Android_files/adFeedback.css" rel="stylesheet"><script>try {  for(var lastpass_iter=0; lastpass_iter < document.forms.length; lastpass_iter++){    var lastpass_f = document.forms[lastpass_iter];    if(typeof(lastpass_f.lpsubmitorig)=="undefined"){      if (typeof(lastpass_f.submit) == "function") {        lastpass_f.lpsubmitorig = lastpass_f.submit;        lastpass_f.submit = function(){          var form = this;          try {            if (document.documentElement && 'createEvent' in document)            {              var forms = document.getElementsByTagName('form');              for (var i=0 ; i<forms.length ; ++i)                if (forms[i]==form)                {                  var element = document.createElement('lpformsubmitdataelement');                  element.setAttribute('formnum',i);                  element.setAttribute('from','submithook');                  document.documentElement.appendChild(element);                  var evt = document.createEvent('Events');                  evt.initEvent('lpformsubmit',true,false);                  element.dispatchEvent(evt);                  break;                }            }          } catch (e) {}          try {            form.lpsubmitorig();          } catch (e) {}        }      }    }  }} catch (e) {}</script><link href="Implementing%20a%20customized%20drawable%20in%20Android_files/jobs.css" rel="stylesheet" type="text/css"></head>
<body class="question-page new-topbar">
    <noscript><div id="noscript-padding"></div></noscript>
    <div id="notify-container"></div>
    <div id="overlay-header"></div>
    <div id="custom-header"></div>




<div class="topbar">
    <div class="topbar-wrapper">

        <div class="js-topbar-dialog-corral">

<div class="topbar-dialog siteSwitcher-dialog dno">
    <div class="header">
        <h3><a href="http://stackoverflow.com/">current community</a></h3>
    </div>
    <div class="modal-content current-site-container">
        <ul class="current-site">
                <li>
                        <div class="related-links">
            <a href="http://chat.stackoverflow.com/" class="js-gps-track" data-gps-track="site_switcher.click({ item_type:6 })">chat</a>
                    <a href="http://blog.stackoverflow.com/" class="js-gps-track" data-gps-track="site_switcher.click({ item_type:7 })">blog</a>
            </div>




    <a href="http://stackoverflow.com/" class="current-site-link site-link js-gps-track" data-id="1" data-gps-track="
        site_switcher.click({ item_type:3 })">
        <div class="site-icon favicon favicon-stackoverflow" title="Stack Overflow"></div>
        Stack Overflow
    </a>

                </li>
                <li class="related-site">
                        <div class="L-shaped-icon-container">
        <span class="L-shaped-icon"></span>
    </div>

                    



    <a href="http://meta.stackoverflow.com/" class="site-link js-gps-track" data-id="552" data-gps-track="
            site.switch({ target_site:552, item_type:3 }),
        site_switcher.click({ item_type:4 })">
        <div class="site-icon favicon favicon-stackoverflowmeta" title="Meta Stack Overflow"></div>
        Meta Stack Overflow
    </a>

                </li>
                            <li class="related-site">
                        <div class="L-shaped-icon-container">
        <span class="L-shaped-icon"></span>
    </div>

                    <a class="site-link js-gps-track" href="http://careers.stackoverflow.com/?utm_source=stackoverflow.com&amp;utm_medium=site-ui&amp;utm_campaign=multicollider" data-gps-track="site_switcher.click({ item_type:9 })">
                        <div class="site-icon favicon favicon-careers" title="Stack Overflow Careers"></div>
                        Stack Overflow Careers
                    </a>
                </li>
        </ul>
    </div>
    
    <div class="header" id="your-communities-header">
        <h3>
your communities        </h3>
            
    </div>
    <div class="modal-content" id="your-communities-section">
            
            <div class="call-to-login">
<a href="https://stackoverflow.com/users/signup?returnurl=http%3a%2f%2fstackoverflow.com%2fquestions%2f2967904%2fimplementing-a-customized-drawable-in-android" class="login-link js-gps-track" data-gps-track="site_switcher.click({ item_type:10 })">Sign up</a> or <a href="https://stackoverflow.com/users/login?returnurl=http%3a%2f%2fstackoverflow.com%2fquestions%2f2967904%2fimplementing-a-customized-drawable-in-android" class="login-link js-gps-track" data-gps-track="site_switcher.click({ item_type:11 })">log in</a> to customize your list.
            </div>
    </div>
    
    <div class="header">
        <h3><a href="http://stackexchange.com/sites">more stack exchange communities</a></h3>
    </div>
    <div class="modal-content">
            <div class="child-content"></div>
    </div>
</div>
        </div>

        <div class="network-items">

            <a href="http://stackexchange.com/" class="topbar-icon icon-site-switcher yes-hover js-site-switcher-button js-gps-track" data-gps-track="site_switcher.show" title="A list of all 138 Stack Exchange sites">
                <span class="hidden-text">Stack Exchange</span>
            </a>

        </div>

        <div class="topbar-links">

                <div class="links-container">
                <span class="topbar-menu-links">
                                <a href="https://stackoverflow.com/users/signup?returnurl=http%3a%2f%2fstackoverflow.com%2fquestions%2f2967904%2fimplementing-a-customized-drawable-in-android" class="login-link">sign up</a>
                                <a href="https://stackoverflow.com/users/login?returnurl=http%3a%2f%2fstackoverflow.com%2fquestions%2f2967904%2fimplementing-a-customized-drawable-in-android" class="login-link">log in</a>

                        <a href="http://stackoverflow.com/tour">tour</a>
                            <a href="#" class="icon-help js-help-button" title="Help Center and other resources">
        help
        <span class="triangle"></span>
    </a>
    <div class="topbar-dialog help-dialog js-help-dialog dno">
        <div class="modal-content">
            <ul>
                                    <li>
                        <a href="http://stackoverflow.com/tour" class="js-gps-track" data-gps-track="help_popup.click({ item_type:1 })">
                            Tour
                            <span class="item-summary">
                                Start here for a quick overview of the site
                            </span>
                        </a>
                    </li>
                <li>
                    <a href="http://stackoverflow.com/help" class="js-gps-track" data-gps-track="help_popup.click({ item_type:4 })">
                        Help Center
                        <span class="item-summary">
                            Detailed answers to any questions you might have
                        </span>
                    </a>
                </li>
                    <li>
                        <a href="http://meta.stackoverflow.com/" class="js-gps-track" data-gps-track="help_popup.click({ item_type:2 })">
                            Meta
                            <span class="item-summary">
                                Discuss the workings and policies of this site
                            </span>
                        </a>
                    </li>
            </ul>
        </div>
    </div>

                            <a href="http://careers.stackoverflow.com/?utm_source=stackoverflow.com&amp;utm_medium=site-ui&amp;utm_campaign=anon-topbar">stack overflow careers</a>
                    </span>
                </div>

            <div class="search-container">
                <form id="search" action="/search" method="get" autocomplete="off">
                    <input name="q" placeholder="search" tabindex="1" autocomplete="off" maxlength="240" type="text">
                </form>
            </div>

        </div>
    </div>
</div>
    <script>
        StackExchange.ready(function() { StackExchange.topbar.init(); });
    </script>

    <div class="container">
        <div id="header">
            <br class="cbt">
            <div id="hlogo">
                <a href="http://stackoverflow.com/">
                    Stack Overflow
                </a>
            </div>
            <div id="hmenus">
                <div class="nav mainnavs">
                    <ul>
                        <li class="youarehere"><a id="nav-questions" href="http://stackoverflow.com/questions">Questions</a></li>
                        <li><a id="nav-tags" href="http://stackoverflow.com/tags">Tags</a></li>
                        <li><a id="nav-users" href="http://stackoverflow.com/users">Users</a></li>
                        <li><a id="nav-badges" href="http://stackoverflow.com/help/badges">Badges</a></li>
                        <li><a id="nav-unanswered" href="http://stackoverflow.com/unanswered">Unanswered</a></li>
                    </ul>
                </div>
                <div class="nav askquestion">
                    <ul>
                        <li>
                            <a id="nav-askquestion" href="http://stackoverflow.com/questions/ask">Ask Question</a>
                        </li>
                    </ul>
                </div>
            </div>
        </div>
        



        <div id="content" class="snippet-hidden">
            

<div itemscope="" itemtype="http://schema.org/Question">
	<link itemprop="image" href="http://cdn.sstatic.net/stackoverflow/img/apple-touch-icon.png">
			<!--googleoff: all-->

<div id="herobox-mini">
    <div id="hero-content">
        <span id="controls">
            <a href="http://stackoverflow.com/tour" id="tell-me-more" class="button">Take the 2-minute tour</a>
            <span id="close"><a title="click to dismiss">×</a></span>
        </span>
        <div id="blurb">
            Stack Overflow is a question and answer site for 
professional and enthusiast programmers. It's 100% free, no registration
 required.
        </div>        
    </div>
    <script>
        $('#tell-me-more').click(function () {
            var clickSource = $("body").attr("class") + '-mini';
            if ($("body").hasClass("questions-page")) {
                clickSource = 'questionpagemini';
            } else if ($("body").hasClass("question-page")) {
                clickSource = 'questionpagemini';
            } else if ($("body").hasClass("home-page")) {
                clickSource = 'homepagemini';
            }

            StackExchange.using("gps", function () {
                StackExchange.gps.track("aboutpage.click", { aboutclick_location: clickSource } , true);
            });
        });
        $('#herobox-mini #close').click(function () {
            StackExchange.using("gps", function () {
                StackExchange.gps.track("hero.action", { hero_action_type: "close" }, true);
            });
            $.cookie("hero", "none", { path: "/", expires: 365 });
            var $hero = $("#herobox-mini");
            $hero.slideUp('fast', function () { $hero.remove(); });
            return false;
        });
    </script>
</div>
			<!--googleon: all-->
			<div id="question-header">
			<h1 itemprop="name"><a href="http://stackoverflow.com/questions/2967904/implementing-a-customized-drawable-in-android" class="question-hyperlink">Implementing a customized drawable in Android</a></h1>
		</div>
			<div id="mainbar">

			

<div class="question" data-questionid="2967904" id="question">

    <script>
                var ados = ados || {};ados.run = ados.run || [];
                ados.run.push(function() { ados_add_placement(22,8277,"adzerk1130690993",4).setZone(43) ; });                    
            </script>
            <div class="everyonelovesstackoverflow adzerk-vote" id="adzerk1130690993"><a href="http://engine.adzerk.net/r?e=eyJhdiI6NDE0LCJhdCI6NCwiYnQiOjAsImNtIjoxODY2MjQsImNoIjoxMTc4LCJjciI6Njk1NzEyLCJkaSI6IjE4YTUzN2YyNWJiZDQ5Njg5MDQyNGU1OTc5MDVkZDY0IiwiZG0iOjEsImZjIjo3MjE4MDYsImZsIjo0MzE3ODAsImlwIjoiMTQuMTY5LjQ0LjEiLCJrdyI6ImFuZHJvaWQiLCJudyI6MjIsInBjIjowLCJwciI6MTYwNCwicnQiOjEsInJmIjoiaHR0cDovL3d3dy5nb29nbGUuY29tL3VybD9zYT10JnJjdD1qJnE9JmVzcmM9cyZzb3VyY2U9d2ViJmNkPTMmdmVkPTBDQzRRRmpBQyZ1cmw9aHR0cDovL3N0YWNrb3ZlcmZsb3cuY29tL3F1ZXN0aW9ucy8yOTY3OTA0L2ltcGxlbWVudGluZy1hLWN1c3RvbWl6ZWQtZHJhd2FibGUtaW4tYW5kcm9pZCZlaT1vN0VCVmMtR044T0U4Z1d2MUlMZ0RBJnVzZz1BRlFqQ05FVDBSRXpjTm55NE9yejBMRk8td1htR3B2WWp3JmJ2bT1idi44NzkyMDcyNixkLmRHYyZjYWQ9cmphIiwic3QiOjgyNzcsInVrIjoidWUxLTQzNGFlNmQyZmZkYjQ0OTNiZDZlNTM1ZDhjZmU4ODEwIiwiem4iOjQzLCJ0cyI6MTQyNjE3NDM3OTg0NSwiYmYiOnRydWUsInBuIjoiYWR6ZXJrMTEzMDY5MDk5MyIsInVyIjoiaHR0cDovL2NhcmVlcnMuc3RhY2tvdmVyZmxvdy5jb20vam9icy9yZW1vdGU_dXRtX3NvdXJjZT1zdGFja292ZXJmbG93LmNvbSZ1dG1fbWVkaXVtPWFkJnV0bV9jYW1wYWlnbj1jYW5kaWRhdGVzLXdmaCZ1dG1fY29udGVudD1sYi13ZmgtYW55d2hlcmV-In0&amp;s=dAS4zwZzyjB09B0_R2czapkhm60" rel="nofollow" target="_blank" title=""><img src="Implementing%20a%20customized%20drawable%20in%20Android_files/ed3b3bbfd4364176bfd1feb8506577ed.jpg" title="" alt="" border="0" height="90" width="728"></a><div class="adzerk-vote-controls" style="display: none;"><div class="adzerk-vote-option adzerk-vote-up"><div class="adzerk-vote-icon"></div></div><div class="adzerk-vote-option adzerk-vote-down"><div class="adzerk-vote-icon"></div></div></div><div class="adzerk-vote-survey" style="display:none;"><form><span>No problem. We won't show you that ad again. Why didn't you like it?</span><ul><li><label><input value="12" name="downvoteReason" type="radio">Uninteresting</label></li><li><label><input value="13" name="downvoteReason" type="radio">Misleading</label></li><li><label><input value="14" name="downvoteReason" type="radio">Offensive</label></li><li><label><input value="15" name="downvoteReason" type="radio">Repetitive</label></li><li><label><input value="16" name="downvoteReason" type="radio">Other</label></li></ul><a href="#" class="adzerk-vote-cancel">Oops! I didn't mean to do this.</a></form></div><img src="Implementing%20a%20customized%20drawable%20in%20Android_files/i_004.gif" style="position:absolute;" border="0" height="0px" width="0px"></div>    <table>
        <tbody><tr>
            <td class="votecell">
                

<div class="vote">
    <input name="_id_" value="2967904" type="hidden">
    <a class="vote-up-off" title="This question shows research effort; it is useful and clear">up vote</a>
    <span itemprop="upvoteCount" class="vote-count-post ">6</span>
    <a class="vote-down-off" title="This question does not show any research effort; it is unclear or not useful">down vote</a>
    
    <a class="star-off" href="#" title="This is a favorite question (click again to undo)">favorite</a>
    <div class="favoritecount"><b>5</b></div>   

</div>

            </td>
            
<td class="postcell">
<div>
    <div class="post-text" itemprop="text">

        <p>I was trying to get hold of 2D graphics in Android.
  As a example i want to implement a custom drawable and show it in my Activity</p>

<p>I have defined a customized drawable by extending from Android drawable as mentioned below</p>

<pre style="" class="default prettyprint prettyprinted"><code><span class="pln"> </span><span class="kwd">class</span><span class="pln"> myDrawable </span><span class="kwd">extends</span><span class="pln"> </span><span class="typ">Drawable</span><span class="pln"> </span><span class="pun">{</span><span class="pln">

   </span><span class="kwd">private</span><span class="pln"> </span><span class="kwd">static</span><span class="pln"> </span><span class="kwd">final</span><span class="pln"> </span><span class="typ">String</span><span class="pln"> TAG </span><span class="pun">=</span><span class="pln"> myDrawable</span><span class="pun">.</span><span class="kwd">class</span><span class="pun">.</span><span class="pln">getSimpleName</span><span class="pun">();</span><span class="pln">
   </span><span class="kwd">private</span><span class="pln"> </span><span class="typ">ColorFilter</span><span class="pln"> cf</span><span class="pun">;</span><span class="pln">
   </span><span class="lit">@Override</span><span class="pln">
   </span><span class="kwd">public</span><span class="pln"> </span><span class="kwd">void</span><span class="pln"> draw</span><span class="pun">(</span><span class="typ">Canvas</span><span class="pln"> canvas</span><span class="pun">)</span><span class="pln"> </span><span class="pun">{</span><span class="pln">


     </span><span class="com">//First you define a colour for the outline of your rectangle</span><span class="pln">

     </span><span class="typ">Paint</span><span class="pln"> rectanglePaint </span><span class="pun">=</span><span class="pln"> </span><span class="kwd">new</span><span class="pln"> </span><span class="typ">Paint</span><span class="pun">();</span><span class="pln">
     rectanglePaint</span><span class="pun">.</span><span class="pln">setARGB</span><span class="pun">(</span><span class="lit">255</span><span class="pun">,</span><span class="pln"> </span><span class="lit">255</span><span class="pun">,</span><span class="pln"> </span><span class="lit">0</span><span class="pun">,</span><span class="pln"> </span><span class="lit">0</span><span class="pun">);</span><span class="pln">
     rectanglePaint</span><span class="pun">.</span><span class="pln">setStrokeWidth</span><span class="pun">(</span><span class="lit">2</span><span class="pun">);</span><span class="pln">
     rectanglePaint</span><span class="pun">.</span><span class="pln">setStyle</span><span class="pun">(</span><span class="typ">Style</span><span class="pun">.</span><span class="pln">FILL</span><span class="pun">);</span><span class="pln">

     </span><span class="com">//Then create yourself a Rectangle</span><span class="pln">
     </span><span class="typ">RectF</span><span class="pln"> rectangle </span><span class="pun">=</span><span class="pln"> </span><span class="kwd">new</span><span class="pln"> </span><span class="typ">RectF</span><span class="pun">(</span><span class="lit">15.0f</span><span class="pun">,</span><span class="pln"> </span><span class="lit">50.0f</span><span class="pun">,</span><span class="pln"> </span><span class="lit">55.0f</span><span class="pun">,</span><span class="pln"> </span><span class="lit">75.0f</span><span class="pun">);</span><span class="pln"> </span><span class="com">//in pixels</span><span class="pln">


     </span><span class="typ">Log</span><span class="pun">.</span><span class="pln">d</span><span class="pun">(</span><span class="pln">TAG</span><span class="pun">,</span><span class="str">"On Draw method"</span><span class="pun">);</span><span class="pln">
     </span><span class="com">// TODO Auto-generated method stub</span><span class="pln">
     </span><span class="typ">Paint</span><span class="pln"> paintHandl </span><span class="pun">=</span><span class="pln"> </span><span class="kwd">new</span><span class="pln"> </span><span class="typ">Paint</span><span class="pun">();</span><span class="pln">
     </span><span class="com">//  paintHandl.setColor(0xaabbcc);</span><span class="pln">
     paintHandl</span><span class="pun">.</span><span class="pln">setARGB</span><span class="pun">(</span><span class="lit">125</span><span class="pun">,</span><span class="pln"> </span><span class="lit">234</span><span class="pun">,</span><span class="pln"> </span><span class="lit">213</span><span class="pun">,</span><span class="pln"> </span><span class="lit">34</span><span class="pln"> </span><span class="pun">);</span><span class="pln">
     </span><span class="typ">RectF</span><span class="pln"> rectObj </span><span class="pun">=</span><span class="pln"> </span><span class="kwd">new</span><span class="pln"> </span><span class="typ">RectF</span><span class="pun">(</span><span class="lit">5</span><span class="pun">,</span><span class="lit">5</span><span class="pun">,</span><span class="lit">25</span><span class="pun">,</span><span class="lit">25</span><span class="pun">);</span><span class="pln">
     canvas</span><span class="pun">.</span><span class="pln">drawRoundRect</span><span class="pun">(</span><span class="pln">rectangle</span><span class="pun">,</span><span class="pln"> </span><span class="lit">0.5f</span><span class="pun">,</span><span class="pln"> </span><span class="lit">0.5f</span><span class="pun">,</span><span class="pln"> rectanglePaint</span><span class="pun">);</span><span class="pln">

   </span><span class="pun">}</span><span class="pln">

   </span><span class="lit">@Override</span><span class="pln">
   </span><span class="kwd">public</span><span class="pln"> </span><span class="kwd">int</span><span class="pln"> getOpacity</span><span class="pun">()</span><span class="pln"> </span><span class="pun">{</span><span class="pln">
     </span><span class="com">// TODO Auto-generated method stub</span><span class="pln">
     </span><span class="kwd">return</span><span class="pln"> </span><span class="lit">100</span><span class="pun">;</span><span class="pln">
   </span><span class="pun">}</span><span class="pln">

   </span><span class="lit">@Override</span><span class="pln">
   </span><span class="kwd">public</span><span class="pln"> </span><span class="kwd">void</span><span class="pln"> setAlpha</span><span class="pun">(</span><span class="kwd">int</span><span class="pln"> alpha</span><span class="pun">)</span><span class="pln"> </span><span class="pun">{</span><span class="pln">
     </span><span class="com">// TODO Auto-generated method stub</span><span class="pln">
   </span><span class="pun">}</span><span class="pln">

   </span><span class="lit">@Override</span><span class="pln">
   </span><span class="kwd">public</span><span class="pln"> </span><span class="kwd">void</span><span class="pln"> setColorFilter</span><span class="pun">(</span><span class="typ">ColorFilter</span><span class="pln"> cf</span><span class="pun">)</span><span class="pln"> </span><span class="pun">{</span><span class="pln">
     </span><span class="com">// TODO Auto-generated method stub</span><span class="pln">
     </span><span class="kwd">this</span><span class="pun">.</span><span class="pln">cf </span><span class="pun">=</span><span class="pln"> cf</span><span class="pun">;</span><span class="pln">
   </span><span class="pun">}</span><span class="pln">
 </span><span class="pun">}</span></code></pre>

<p>I am trying to get this displayed in my activity, as shown below</p>

<pre style="" class="default prettyprint prettyprinted"><code><span class="kwd">public</span><span class="pln"> </span><span class="kwd">class</span><span class="pln"> custDrawable </span><span class="kwd">extends</span><span class="pln"> </span><span class="typ">Activity</span><span class="pln"> </span><span class="pun">{</span><span class="pln">
</span><span class="com">/** Called when the activity is first created. */</span><span class="pln">


 </span><span class="typ">LinearLayout</span><span class="pln"> layObj </span><span class="pun">=</span><span class="pln"> </span><span class="kwd">null</span><span class="pun">;</span><span class="pln">
    </span><span class="lit">@Override</span><span class="pln">
    </span><span class="kwd">public</span><span class="pln"> </span><span class="kwd">void</span><span class="pln"> onCreate</span><span class="pun">(</span><span class="typ">Bundle</span><span class="pln"> savedInstanceState</span><span class="pun">)</span><span class="pln"> </span><span class="pun">{</span><span class="pln">
        </span><span class="kwd">super</span><span class="pun">.</span><span class="pln">onCreate</span><span class="pun">(</span><span class="pln">savedInstanceState</span><span class="pun">);</span><span class="pln">
        setContentView</span><span class="pun">(</span><span class="pln">R</span><span class="pun">.</span><span class="pln">layout</span><span class="pun">.</span><span class="pln">main</span><span class="pun">);</span><span class="pln">
        layObj </span><span class="pun">=</span><span class="pln"> </span><span class="pun">(</span><span class="typ">LinearLayout</span><span class="pun">)</span><span class="pln"> findViewById</span><span class="pun">(</span><span class="pln">R</span><span class="pun">.</span><span class="pln">id</span><span class="pun">.</span><span class="pln">parentLay</span><span class="pun">);</span><span class="pln">
        </span><span class="typ">ImageView</span><span class="pln"> imageView </span><span class="pun">=</span><span class="pln"> </span><span class="pun">(</span><span class="typ">ImageView</span><span class="pun">)</span><span class="pln"> findViewById</span><span class="pun">(</span><span class="pln">R</span><span class="pun">.</span><span class="pln">id</span><span class="pun">.</span><span class="pln">icon2</span><span class="pun">);</span><span class="pln">
        myDrawable myDrawObj </span><span class="pun">=</span><span class="pln"> </span><span class="kwd">new</span><span class="pln"> myDrawable</span><span class="pun">();</span><span class="pln">
        imageView</span><span class="pun">.</span><span class="pln">setImageDrawable</span><span class="pun">(</span><span class="pln">myDrawObj</span><span class="pun">);</span><span class="pln">
        imageView</span><span class="pun">.</span><span class="pln">invalidate</span><span class="pun">();</span><span class="pln">
</span><span class="com">//  layObj.addView(myDrawObj, params);</span><span class="pln">

    </span><span class="pun">}</span><span class="pln">
</span><span class="pun">}</span></code></pre>

<p>But when i run the app i see no rectangle on the activity, can anyone help me out?
Where am i going wrong?</p>

    </div>
    <div class="post-taglist">
        <a href="http://stackoverflow.com/questions/tagged/android" class="post-tag js-gps-track" title="show questions tagged 'android'" rel="tag"><img src="Implementing%20a%20customized%20drawable%20in%20Android_files/tKsDb.png" alt="" class="sponsor-tag-img" height="16" width="18">android</a> 
    </div>
    <table class="fw">
    <tbody><tr>
    <td class="vt">
<div class="post-menu"><a href="http://stackoverflow.com/q/2967904" title="short permalink to this question" class="short-link" id="link-post-2967904">share</a><span class="lsep">|</span><a href="http://stackoverflow.com/posts/2967904/edit" class="suggest-edit-post" title="">improve this question</a></div>        
    </td>
    <td class="post-signature" align="right">
<div class="user-info ">
    <div class="user-action-time">
        <a href="http://stackoverflow.com/posts/2967904/revisions" title="show all edits to this post">edited <span title="2015-03-09 12:54:45Z" class="relativetime">Mar 9 at 12:54</span></a>
    </div>
    <div class="user-gravatar32">
        <a href="http://stackoverflow.com/users/502735/dalinaum"><div class="gravatar-wrapper-32"><img src="Implementing%20a%20customized%20drawable%20in%20Android_files/64c1a3841da6d254ac11d9d842e04ce4.jpg" alt="" height="32" width="32"></div></a>
    </div>
    <div class="user-details">
        <a href="http://stackoverflow.com/users/502735/dalinaum">Dalinaum</a><br>
        <span class="reputation-score" title="reputation score " dir="ltr">583</span><span title="7 silver badges"><span class="badge2"></span><span class="badgecount">7</span></span><span title="18 bronze badges"><span class="badge3"></span><span class="badgecount">18</span></span>
    </div>
</div>    </td>
    <td class="post-signature owner">
        <div class="user-info ">
    <div class="user-action-time">
        asked <span title="2010-06-03 16:29:27Z" class="relativetime">Jun 3 '10 at 16:29</span>
    </div>
    <div class="user-gravatar32">
        <a href="http://stackoverflow.com/users/357709/girish"><div class="gravatar-wrapper-32"><img src="Implementing%20a%20customized%20drawable%20in%20Android_files/618104bb9e362f3da50094bb32f96b68.png" alt="" height="32" width="32"></div></a>
    </div>
    <div class="user-details">
        <a href="http://stackoverflow.com/users/357709/girish">Girish</a><br>
        <span class="reputation-score" title="reputation score " dir="ltr">31</span><span title="1 gold badge"><span class="badge1"></span><span class="badgecount">1</span></span><span title="1 silver badge"><span class="badge2"></span><span class="badgecount">1</span></span><span title="4 bronze badges"><span class="badge3"></span><span class="badgecount">4</span></span>
    </div>
</div>
    </td>
    </tr>
    </tbody></table>
</div>
</td>
        </tr>
                
<tr>
    <td class="votecell"></td>
    <td>
	    <div id="comments-2967904" class="comments  dno">
		    <table>
                <tbody data-remaining-comments-count="0" data-canpost="false" data-cansee="true" data-comments-unavailable="false" data-addlink-disabled="true">

                        <tr><td></td><td></td></tr>
                </tbody>
		    </table>
	    </div>

        <div id="comments-link-2967904" data-rep="50" data-anon="true">

                <a class="js-add-link comments-link disabled-link " title="Use comments to ask for more information or suggest improvements. Avoid answering questions in comments.">add a comment</a><span class="js-link-separator dno">&nbsp;|&nbsp;</span>
            <a class="js-show-link comments-link dno" title="expand to show all comments on this post, or add one of your own" href="#" onclick=""></a>
        </div>         
    </td>
</tr>        </tbody></table>
</div>

			<div id="answers">

				<a name="tab-top"></a>
				<div id="answers-header">
					<div class="subheader answers-subheader">
						<h2>
								2 Answers
                                <span style="display:none;" itemprop="answerCount">2</span>
						</h2>
						<div>
							<div id="tabs">
        <a href="http://stackoverflow.com/questions/2967904/implementing-a-customized-drawable-in-android?answertab=active#tab-top" title="Answers with the latest activity first">active</a>
        <a href="http://stackoverflow.com/questions/2967904/implementing-a-customized-drawable-in-android?answertab=oldest#tab-top" title="Answers in the order they were provided">oldest</a>
        <a class="youarehere" href="http://stackoverflow.com/questions/2967904/implementing-a-customized-drawable-in-android?answertab=votes#tab-top" title="Answers with the highest score first">votes</a>
</div>
						</div>
					</div>    
				</div>    




  
<a name="2968815"></a>
<div id="answer-2968815" class="answer" data-answerid="2968815" itemscope="" itemtype="http://schema.org/Answer">
    <table>
        <tbody><tr>
            <td class="votecell">
                

<div class="vote">
    <input name="_id_" value="2968815" type="hidden">
    <a class="vote-up-off" title="This answer is useful">up vote</a>
    <span itemprop="upvoteCount" class="vote-count-post ">8</span>
    <a class="vote-down-off" title="This answer is not useful">down vote</a>
    


</div>

            </td>
            


<td class="answercell">
    <div class="post-text" itemprop="text">
<p>Your problem is in the <code>getOpacity()</code> method.  100 is not a valid value.  You should use a <a href="http://developer.android.com/intl/fr/reference/android/graphics/PixelFormat.html">PixelFormat</a> value.  Also, you should create your <code>RectF</code> and <code>Paint</code> in the constructor and then just adjust the values in <code>draw()</code> so you don't create so many objects that need garbage collected.  Like this:</p>

<pre style="" class="default prettyprint prettyprinted"><code><span class="kwd">public</span><span class="pln"> </span><span class="kwd">class</span><span class="pln"> </span><span class="typ">Square</span><span class="pln"> </span><span class="kwd">extends</span><span class="pln"> </span><span class="typ">Drawable</span><span class="pln">
</span><span class="pun">{</span><span class="pln">
    </span><span class="kwd">private</span><span class="pln"> </span><span class="kwd">final</span><span class="pln"> </span><span class="typ">Paint</span><span class="pln"> mPaint</span><span class="pun">;</span><span class="pln">
    </span><span class="kwd">private</span><span class="pln"> </span><span class="kwd">final</span><span class="pln"> </span><span class="typ">RectF</span><span class="pln"> mRect</span><span class="pun">;</span><span class="pln">

    </span><span class="kwd">public</span><span class="pln"> </span><span class="typ">Square</span><span class="pun">()</span><span class="pln">
    </span><span class="pun">{</span><span class="pln">
        mPaint </span><span class="pun">=</span><span class="pln"> </span><span class="kwd">new</span><span class="pln"> </span><span class="typ">Paint</span><span class="pun">();</span><span class="pln">
        mRect </span><span class="pun">=</span><span class="pln"> </span><span class="kwd">new</span><span class="pln"> </span><span class="typ">RectF</span><span class="pun">();</span><span class="pln">
    </span><span class="pun">}</span><span class="pln">

    </span><span class="lit">@Override</span><span class="pln">
    </span><span class="kwd">public</span><span class="pln"> </span><span class="kwd">void</span><span class="pln"> draw</span><span class="pun">(</span><span class="typ">Canvas</span><span class="pln"> canvas</span><span class="pun">)</span><span class="pln">
    </span><span class="pun">{</span><span class="pln">
        </span><span class="com">// Set the correct values in the Paint</span><span class="pln">
        mPaint</span><span class="pun">.</span><span class="pln">setARGB</span><span class="pun">(</span><span class="lit">255</span><span class="pun">,</span><span class="pln"> </span><span class="lit">255</span><span class="pun">,</span><span class="pln"> </span><span class="lit">0</span><span class="pun">,</span><span class="pln"> </span><span class="lit">0</span><span class="pun">);</span><span class="pln">
        mPaint</span><span class="pun">.</span><span class="pln">setStrokeWidth</span><span class="pun">(</span><span class="lit">2</span><span class="pun">);</span><span class="pln">
        mPaint</span><span class="pun">.</span><span class="pln">setStyle</span><span class="pun">(</span><span class="typ">Style</span><span class="pun">.</span><span class="pln">FILL</span><span class="pun">);</span><span class="pln">

        </span><span class="com">// Adjust the rect</span><span class="pln">
        mRect</span><span class="pun">.</span><span class="pln">left </span><span class="pun">=</span><span class="pln"> </span><span class="lit">15.0f</span><span class="pun">;</span><span class="pln">
        mRect</span><span class="pun">.</span><span class="pln">top </span><span class="pun">=</span><span class="pln"> </span><span class="lit">50.0f</span><span class="pun">;</span><span class="pln">
        mRect</span><span class="pun">.</span><span class="pln">right </span><span class="pun">=</span><span class="pln"> </span><span class="lit">55.0f</span><span class="pun">;</span><span class="pln">
        mRect</span><span class="pun">.</span><span class="pln">bottom </span><span class="pun">=</span><span class="pln"> </span><span class="lit">75.0f</span><span class="pun">;</span><span class="pln">

        </span><span class="com">// Draw it</span><span class="pln">
        canvas</span><span class="pun">.</span><span class="pln">drawRoundRect</span><span class="pun">(</span><span class="pln">mRect</span><span class="pun">,</span><span class="pln"> </span><span class="lit">0.5f</span><span class="pun">,</span><span class="pln"> </span><span class="lit">0.5f</span><span class="pun">,</span><span class="pln"> mPaint</span><span class="pun">);</span><span class="pln">
    </span><span class="pun">}</span><span class="pln">

    </span><span class="lit">@Override</span><span class="pln">
    </span><span class="kwd">public</span><span class="pln"> </span><span class="kwd">int</span><span class="pln"> getOpacity</span><span class="pun">()</span><span class="pln">
    </span><span class="pun">{</span><span class="pln">
        </span><span class="kwd">return</span><span class="pln"> </span><span class="typ">PixelFormat</span><span class="pun">.</span><span class="pln">OPAQUE</span><span class="pun">;</span><span class="pln">
    </span><span class="pun">}</span><span class="pln">

    </span><span class="lit">@Override</span><span class="pln">
    </span><span class="kwd">public</span><span class="pln"> </span><span class="kwd">void</span><span class="pln"> setAlpha</span><span class="pun">(</span><span class="kwd">int</span><span class="pln"> arg0</span><span class="pun">)</span><span class="pln">
    </span><span class="pun">{</span><span class="pln">
    </span><span class="pun">}</span><span class="pln">

    </span><span class="lit">@Override</span><span class="pln">
    </span><span class="kwd">public</span><span class="pln"> </span><span class="kwd">void</span><span class="pln"> setColorFilter</span><span class="pun">(</span><span class="typ">ColorFilter</span><span class="pln"> arg0</span><span class="pun">)</span><span class="pln">
    </span><span class="pun">{</span><span class="pln">
    </span><span class="pun">}</span><span class="pln">
</span><span class="pun">}</span></code></pre>
    </div>
    <table class="fw">
    <tbody><tr>
    <td class="vt">
<div class="post-menu"><a href="http://stackoverflow.com/a/2968815" title="short permalink to this answer" class="short-link" id="link-post-2968815">share</a><span class="lsep">|</span><a href="http://stackoverflow.com/posts/2968815/edit" class="suggest-edit-post" title="">improve this answer</a></div>                    </td>
            


    <td class="post-signature" align="right">   
       

    <div class="user-info user-hover">
    <div class="user-action-time">
        answered <span title="2010-06-03 18:41:55Z" class="relativetime">Jun 3 '10 at 18:41</span>
    </div>
    <div class="user-gravatar32">
        <a href="http://stackoverflow.com/users/236136/caseyb"><div class="gravatar-wrapper-32"><img src="Implementing%20a%20customized%20drawable%20in%20Android_files/0e19db7587af9b97db7aa2db7d1eb909.jpg" alt="" height="32" width="32"></div></a>
    </div>
    <div class="user-details">
        <a href="http://stackoverflow.com/users/236136/caseyb">CaseyB</a><br>
        <span class="reputation-score" title="reputation score 16307" dir="ltr">16.3k</span><span title="6 gold badges"><span class="badge1"></span><span class="badgecount">6</span></span><span title="44 silver badges"><span class="badge2"></span><span class="badgecount">44</span></span><span title="78 bronze badges"><span class="badge3"></span><span class="badgecount">78</span></span>
    </div>
</div>
    </td>
    </tr>
    </tbody></table>
</td>
        </tr>
        
<tr>
    <td class="votecell"></td>
    <td>
	    <div id="comments-2968815" class="comments ">
		    <table>
                <tbody data-remaining-comments-count="1" data-canpost="false" data-cansee="true" data-comments-unavailable="false" data-addlink-disabled="true">



    <tr id="comment-3031917" class="comment ">
        <td>
            <table>
                <tbody>
                    <tr>
                        <td class=" comment-score">
                                &nbsp;&nbsp;
                        </td>
                        <td>
                                &nbsp;
                        </td>
                    </tr>
                </tbody>
            </table>
        </td>
        <td class="comment-text">
            <div style="display: block;" class="comment-body">
                <span class="comment-copy">I did the changes mentioned by casey, but still i am not able to see any valid stuff drawn on my view.</span>
                –&nbsp;
                    <a href="http://stackoverflow.com/users/357709/girish" title="31 reputation" class="comment-user owner">Girish</a>
                <span class="comment-date" dir="ltr"><a class="comment-link" href="#comment3031917_2968815"><span title="2010-06-04 06:29:06Z" class="relativetime-clean">Jun 4 '10 at 6:29</span></a></span>
                                                                            </div>
                    </td>
    </tr>
    <tr id="comment-3053849" class="comment ">
        <td>
            <table>
                <tbody>
                    <tr>
                        <td class=" comment-score">
                                &nbsp;&nbsp;
                        </td>
                        <td>
                                &nbsp;
                        </td>
                    </tr>
                </tbody>
            </table>
        </td>
        <td class="comment-text">
            <div style="display: block;" class="comment-body">
                <span class="comment-copy">Nother problem is that it seems that you never add the <code>ImageView</code> to your <code>LinearLayout</code>.  You need to add <code>layObj.addView(imageView);</code> to the end of <code>onCreate()</code></span>
                –&nbsp;
                    <a href="http://stackoverflow.com/users/236136/caseyb" title="16307 reputation" class="comment-user">CaseyB</a>
                <span class="comment-date" dir="ltr"><a class="comment-link" href="#comment3053849_2968815"><span title="2010-06-07 16:17:52Z" class="relativetime-clean">Jun 7 '10 at 16:17</span></a></span>
                    <span class="edited-yes" title="this comment was edited 1 time"></span>
                                                                            </div>
                    </td>
    </tr>
    <tr id="comment-3083257" class="comment ">
        <td>
            <table>
                <tbody>
                    <tr>
                        <td class=" comment-score">
                                &nbsp;&nbsp;
                        </td>
                        <td>
                                &nbsp;
                        </td>
                    </tr>
                </tbody>
            </table>
        </td>
        <td class="comment-text">
            <div style="display: block;" class="comment-body">
                <span class="comment-copy">I have added the imageView to
 linear layout, it is basically a problem with set bounds In xml , i 
hardcoded the width and height of the image view, now it is showing up, 
so some problem with my setBounds is it?</span>
                –&nbsp;
                    <a href="http://stackoverflow.com/users/357709/girish" title="31 reputation" class="comment-user owner">Girish</a>
                <span class="comment-date" dir="ltr"><a class="comment-link" href="#comment3083257_2968815"><span title="2010-06-10 16:38:53Z" class="relativetime-clean">Jun 10 '10 at 16:38</span></a></span>
                                                                            </div>
                    </td>
    </tr>
    <tr id="comment-3083647" class="comment ">
        <td>
            <table>
                <tbody>
                    <tr>
                        <td class=" comment-score">
                                &nbsp;&nbsp;
                        </td>
                        <td>
                                &nbsp;
                        </td>
                    </tr>
                </tbody>
            </table>
        </td>
        <td class="comment-text">
            <div style="display: block;" class="comment-body">
                <span class="comment-copy">Is it possible to embed an 
image with in the rounded rectangle or any primitive shape i draw, say 
polygon or a path? If so can you please share the code?</span>
                –&nbsp;
                    <a href="http://stackoverflow.com/users/357709/girish" title="31 reputation" class="comment-user owner">Girish</a>
                <span class="comment-date" dir="ltr"><a class="comment-link" href="#comment3083647_2968815"><span title="2010-06-10 17:18:06Z" class="relativetime-clean">Jun 10 '10 at 17:18</span></a></span>
                                                                            </div>
                    </td>
    </tr>
    <tr id="comment-3084233" class="comment ">
        <td>
            <table>
                <tbody>
                    <tr>
                        <td class=" comment-score">
                                &nbsp;&nbsp;
                        </td>
                        <td>
                                &nbsp;
                        </td>
                    </tr>
                </tbody>
            </table>
        </td>
        <td class="comment-text">
            <div style="display: block;" class="comment-body">
                <span class="comment-copy">If you override the <code>draw()</code> method you can draw whatever you want to the <code>Canvas</code>.</span>
                –&nbsp;
                    <a href="http://stackoverflow.com/users/236136/caseyb" title="16307 reputation" class="comment-user">CaseyB</a>
                <span class="comment-date" dir="ltr"><a class="comment-link" href="#comment3084233_2968815"><span title="2010-06-10 18:24:42Z" class="relativetime-clean">Jun 10 '10 at 18:24</span></a></span>
                                                                            </div>
                    </td>
    </tr>
                </tbody>
		    </table>
	    </div>

        <div id="comments-link-2968815" data-rep="50" data-anon="true">

                <a class="js-add-link comments-link  dno" title="Use comments to ask for more information or suggest improvements. Avoid comments like “+1” or “thanks”."></a><span class="js-link-separator dno">&nbsp;|&nbsp;</span>
            <a class="js-show-link comments-link " title="expand to show all comments on this post, or add one of your own" href="#" onclick="">show <b>1</b> more comment</a>
        </div>         
    </td>
</tr>    </tbody></table>
</div>
<script>
                var ados = ados || {};ados.run = ados.run || [];
                ados.run.push(function() { ados_add_placement(22,8277,"adzerk1793258707",4).setZone(44) ; });                    
            </script>
            <div class="everyonelovesstackoverflow adzerk-vote" id="adzerk1793258707"><a href="http://engine.adzerk.net/r?e=eyJhdiI6NDE0LCJhdCI6NCwiYnQiOjAsImNtIjoxODY2MjQsImNoIjoxMTc4LCJjciI6Njk1NzM4LCJkaSI6IjVhN2I0ZjU3Mzg0NDQ0OTFiODM3NTgwN2QxYzliMWMyIiwiZG0iOjEsImZjIjo3MjE4MzIsImZsIjo0MzE3ODAsImlwIjoiMTQuMTY5LjQ0LjEiLCJrdyI6ImFuZHJvaWQiLCJudyI6MjIsInBjIjowLCJwciI6MTYwNCwicnQiOjEsInJmIjoiaHR0cDovL3d3dy5nb29nbGUuY29tL3VybD9zYT10JnJjdD1qJnE9JmVzcmM9cyZzb3VyY2U9d2ViJmNkPTMmdmVkPTBDQzRRRmpBQyZ1cmw9aHR0cDovL3N0YWNrb3ZlcmZsb3cuY29tL3F1ZXN0aW9ucy8yOTY3OTA0L2ltcGxlbWVudGluZy1hLWN1c3RvbWl6ZWQtZHJhd2FibGUtaW4tYW5kcm9pZCZlaT1vN0VCVmMtR044T0U4Z1d2MUlMZ0RBJnVzZz1BRlFqQ05FVDBSRXpjTm55NE9yejBMRk8td1htR3B2WWp3JmJ2bT1idi44NzkyMDcyNixkLmRHYyZjYWQ9cmphIiwic3QiOjgyNzcsInVrIjoidWUxLTQzNGFlNmQyZmZkYjQ0OTNiZDZlNTM1ZDhjZmU4ODEwIiwiem4iOjQ0LCJ0cyI6MTQyNjE3NDM3OTg0NywiYmYiOnRydWUsInBuIjoiYWR6ZXJrMTc5MzI1ODcwNyIsInVyIjoiaHR0cDovL2NhcmVlcnMuc3RhY2tvdmVyZmxvdy5jb20vam9icy9yZW1vdGU_dXRtX3NvdXJjZT1zdGFja292ZXJmbG93LmNvbSZ1dG1fbWVkaXVtPWFkJnV0bV9jYW1wYWlnbj1jYW5kaWRhdGVzLXdmaCZ1dG1fY29udGVudD1sYi13Zmgta2lkLXdvcmstb24td29yayJ9&amp;s=6aXYwd1NxMSLvUmhP1sZQqOD19U" rel="nofollow" target="_blank" title=""><img src="Implementing%20a%20customized%20drawable%20in%20Android_files/d47c809dea6241b9933a81fe1d0f7085.jpg" title="" alt="" border="0" height="90" width="728"></a><div class="adzerk-vote-controls" style="display:none;"><div class="adzerk-vote-option adzerk-vote-up"><div class="adzerk-vote-icon"></div></div><div class="adzerk-vote-option adzerk-vote-down"><div class="adzerk-vote-icon"></div></div></div><div class="adzerk-vote-survey" style="display:none;"><form><span>No problem. We won't show you that ad again. Why didn't you like it?</span><ul><li><label><input value="12" name="downvoteReason" type="radio">Uninteresting</label></li><li><label><input value="13" name="downvoteReason" type="radio">Misleading</label></li><li><label><input value="14" name="downvoteReason" type="radio">Offensive</label></li><li><label><input value="15" name="downvoteReason" type="radio">Repetitive</label></li><li><label><input value="16" name="downvoteReason" type="radio">Other</label></li></ul><a href="#" class="adzerk-vote-cancel">Oops! I didn't mean to do this.</a></form></div><img src="Implementing%20a%20customized%20drawable%20in%20Android_files/i_002.gif" style="position:absolute;" border="0" height="0px" width="0px"></div>
  
<a name="27866647"></a>
<div id="answer-27866647" class="answer" data-answerid="27866647" itemscope="" itemtype="http://schema.org/Answer">
    <table>
        <tbody><tr>
            <td class="votecell">
                

<div class="vote">
    <input name="_id_" value="27866647" type="hidden">
    <a class="vote-up-off" title="This answer is useful">up vote</a>
    <span itemprop="upvoteCount" class="vote-count-post ">0</span>
    <a class="vote-down-off" title="This answer is not useful">down vote</a>
    


</div>

            </td>
            


<td class="answercell">
    <div class="post-text" itemprop="text">
<p>You may have to implement other overrides like getIntrinsicWidth() 
and getIntrinsicHeight(). One way to tell is that you set your 
layout_width and layout_height to some constant (layout_width="42dip" 
layout_height="42dip" in XML or setting your layoutParams to some value 
if you are using Java layouts). Some View types handle not having 
getIntrinsic* implemented than others, so try them! This includes a 
straight View </p>

<p>You can try returning -1 if there's no specific width or height. </p>

<p>Hard to tell if the issue ever got resolved, but I got here via 
Google trying to help myself remember the details of making a custom 
Drawable, plus I want to help people avoid this: <a href="http://xkcd.com/979/" rel="nofollow">http://xkcd.com/979/</a></p>
    </div>
    <table class="fw">
    <tbody><tr>
    <td class="vt">
<div class="post-menu"><a href="http://stackoverflow.com/a/27866647" title="short permalink to this answer" class="short-link" id="link-post-27866647">share</a><span class="lsep">|</span><a href="http://stackoverflow.com/posts/27866647/edit" class="suggest-edit-post" title="">improve this answer</a></div>                    </td>
            


    <td class="post-signature" align="right">   
       

    <div class="user-info user-hover">
    <div class="user-action-time">
        answered <span title="2015-01-09 18:12:41Z" class="relativetime">Jan 9 at 18:12</span>
    </div>
    <div class="user-gravatar32">
        <a href="http://stackoverflow.com/users/1524209/joe-plante"><div class="gravatar-wrapper-32"><img src="Implementing%20a%20customized%20drawable%20in%20Android_files/f090818aac804ea2feb1966095b29665.png" alt="" height="32" width="32"></div></a>
    </div>
    <div class="user-details">
        <a href="http://stackoverflow.com/users/1524209/joe-plante">Joe Plante</a><br>
        <span class="reputation-score" title="reputation score " dir="ltr">3,250</span><span title="1 gold badge"><span class="badge1"></span><span class="badgecount">1</span></span><span title="10 silver badges"><span class="badge2"></span><span class="badgecount">10</span></span><span title="15 bronze badges"><span class="badge3"></span><span class="badgecount">15</span></span>
    </div>
</div>
    </td>
    </tr>
    </tbody></table>
</td>
        </tr>
        
<tr>
    <td class="votecell"></td>
    <td>
	    <div id="comments-27866647" class="comments  dno">
		    <table>
                <tbody data-remaining-comments-count="0" data-canpost="false" data-cansee="true" data-comments-unavailable="false" data-addlink-disabled="true">

                        <tr><td></td><td></td></tr>
                </tbody>
		    </table>
	    </div>

        <div id="comments-link-27866647" data-rep="50" data-anon="true">

                <a class="js-add-link comments-link disabled-link " title="Use comments to ask for more information or suggest improvements. Avoid comments like “+1” or “thanks”.">add a comment</a><span class="js-link-separator dno">&nbsp;|&nbsp;</span>
            <a class="js-show-link comments-link dno" title="expand to show all comments on this post, or add one of your own" href="#" onclick=""></a>
        </div>         
    </td>
</tr>    </tbody></table>
</div>
									<a name="new-answer"></a>
						<form id="post-form" action="/questions/2967904/answer/submit" method="post" class="post-form">
						    <input id="post-id" value="2967904" type="hidden">
                            <input id="qualityBanWarningShown" name="qualityBanWarningShown" value="false" type="hidden">
                            <input name="referrer" value="http://www.google.com/url?sa=t&amp;rct=j&amp;q=&amp;esrc=s&amp;source=web&amp;cd=3&amp;ved=0CC4QFjAC&amp;url=http%3A%2F%2Fstackoverflow.com%2Fquestions%2F2967904%2Fimplementing-a-customized-drawable-in-android&amp;ei=o7EBVc-GN8OE8gWv1ILgDA&amp;usg=AFQjCNET0REzcNny4Orz0LFO-wXmGpvYjw&amp;bvm=bv.87920726,d.dGc&amp;cad=rja" type="hidden">
							<h2 class="space">Your Answer</h2>



            <script>
            StackExchange.ifUsing("editor", function () {
                StackExchange.using("externalEditor", function () {
                    StackExchange.using("snippets", function () {
                        StackExchange.snippets.init();
                    });
                });
            }, "code-snippets");
        </script>
    

<script>
    StackExchange.ready(function() {
        initTagRenderer("".split(" "), "".split(" "));
       
        StackExchange.using("externalEditor", function() {
            // Have to fire editor after snippets, if snippets enabled
            if (StackExchange.options.snippets.enabled) {
                StackExchange.using("snippets", function() {
                    createEditor();
                });
            }
            else {
                createEditor();
            }
        });

        function createEditor() {
            prepareEditor({
                heartbeatType: 'answer',
                bindNavPrevention: true,
                postfix: "",
                    onDemand: true,
                    discardSelector: ".discard-answer"
                ,immediatelyShowMarkdownHelp:true
                });
                

        }
    });  
</script>


<div id="post-editor" class="post-editor">

    <div style="position: relative;">     
        <div class="wmd-container">
            <div id="wmd-button-bar" class="wmd-button-bar"><ul id="wmd-button-row" class="wmd-button-row"><li style="left: 0px;" class="wmd-button" id="wmd-bold-button"><span style="background-position: 0px -20px;"></span></li><li style="left: 25px;" class="wmd-button" id="wmd-italic-button"><span style="background-position: -20px -20px;"></span></li><li style="left: 50px;" class="wmd-spacer" id="wmd-spacer1"><span style="background-position: -40px -20px;"></span></li><li style="left: 75px;" class="wmd-button" id="wmd-link-button"><span style="background-position: -40px -20px;"></span></li><li style="left: 100px;" class="wmd-button" id="wmd-quote-button"><span style="background-position: -60px -20px;"></span></li><li style="left: 125px;" class="wmd-button" id="wmd-code-button"><span style="background-position: -80px -20px;"></span></li><li style="left: 150px;" class="wmd-button" id="wmd-image-button"><span style="background-position: -100px -20px;"></span></li><li style="left: 175px;" class="wmd-spacer" id="wmd-spacer2"><span style="background-position: -120px -20px;"></span></li><li style="left: 200px;" class="wmd-button" id="wmd-olist-button"><span style="background-position: -120px -20px;"></span></li><li style="left: 225px;" class="wmd-button" id="wmd-ulist-button"><span style="background-position: -140px -20px;"></span></li><li style="left: 250px;" class="wmd-button" id="wmd-heading-button"><span style="background-position: -160px -20px;"></span></li><li style="left: 275px;" class="wmd-button" id="wmd-hr-button"><span style="background-position: -180px -20px;"></span></li><li style="left: 300px;" class="wmd-spacer" id="wmd-spacer3"><span style="background-position: -200px -20px;"></span></li><li style="left: 325px;" class="wmd-button" id="wmd-undo-button"><span style="background-position: -200px -20px;"></span></li><li style="left: 350px;" class="wmd-button" id="wmd-redo-button"><span style="background-position: -220px -20px;"></span></li></ul></div>
            <textarea id="wmd-input" class="wmd-input" name="post-text" cols="92" rows="15" tabindex="101" data-min-length=""></textarea>
        </div>
    </div>

    <div class="fl" style="margin-top: 8px; height:24px;">&nbsp;</div>
    <div id="draft-saved" class="draft-saved community-option fl" style="margin-top: 8px; height:24px; display:none;">draft saved</div>

    <div id="draft-discarded" class="draft-discarded community-option fl" style="margin-top: 8px; height:24px; display:none;">draft discarded</div>



    <div id="wmd-preview" class="wmd-preview"></div>
    <div></div>
    <div class="edit-block">
        <input id="fkey" name="fkey" value="7d79d500f57d16c8348b0cafce12f3e4" type="hidden">
        <input id="author" name="author" type="text">
    </div>



</div>
							<div style="position: relative;">
								
            <div class="form-item new-post-login">
        
                <div class="new-login-form">
                    <div class="new-login-left">
                        <h3>Sign up or <a id="login-link" href="http://stackoverflow.com/users/login?returnurl=%2fquestions%2f2967904%2fimplementing-a-customized-drawable-in-android%23new-answer">log in</a></h3>
                        <script>
                            StackExchange.ready(function () {
                                StackExchange.helpers.onClickDraftSave('#login-link');
                            });
                        </script>
                        <div class="preferred-login google-login">
                            <p><span class="icon"></span><span>Sign up using Google</span></p>
                        </div>
                        <div class="preferred-login facebook-login">
                            <p><span class="icon"></span><span>Sign up using Facebook</span></p>
                        </div>
                        <div class="preferred-login stackexchange-login">
                            <p><span class="icon"></span><span>Sign up using Stack Exchange</span></p>
                        </div>
                    </div>
                    <input name="manual-openid" class="manual-openid" type="hidden">
                    <input name="use-facebook" class="use-facebook" value="false" type="hidden">
                    <input name="use-google" class="use-google" value="false" type="hidden">
                    <input class="submit-openid" value="Submit" style="display:none" type="button">
                    <div class="new-login-right">
                                <h3>Post as a guest</h3>
    <div class="form-item">
        <table>
        <tbody><tr>
                    <td class="vm">
                <div>
                    <label for="display-name">Name</label>
                    <input id="display-name" name="display-name" size="30" maxlength="30" tabindex="105" type="text">
                </div>
                <div>
                    <label for="m-address">Email</label>
                    <input id="m-address" name="m-address" size="30" maxlength="100" tabindex="106" placeholder="required, but never shown" type="email">
                </div>
            </td>
        </tr>
        </tbody></table>
    </div>

                    </div>
                </div>
            </div>
            <script>
                StackExchange.ready(
                    function () {
                        StackExchange.openid.initPostLogin('.new-post-login', '%2fquestions%2f2967904%2fimplementing-a-customized-drawable-in-android%23new-answer');
                    }
                );
            </script>
            <noscript>
                        <h3>Post as a guest</h3>
    <div class="form-item">
        <table>
        <tr>
                    <td class="vm">
                <div>
                    <label for="display-name">Name</label>
                    <input id="display-name" name="display-name" type="text" size="30" maxlength="30" value="" tabindex="105">
                </div>
                <div>
                    <label for="m-address">Email</label>
                    <input id="m-address" name="m-address" type="email" size="30" maxlength="100" value="" tabindex="106" placeholder="required, but never shown" />
                </div>
            </td>
        </tr>
        </table>
    </div>

            </noscript>
							</div>
           
															<div class="form-submit cbt">
									<input id="submit-button" value="Post Your Answer" tabindex="110" type="submit">
									<a href="#" class="discard-answer dno">discard</a>

<p class="privacy-policy-agreement">
By posting your answer, you agree to the <a href="http://stackexchange.com/legal/privacy-policy" target="_blank">privacy policy</a> and <a href="http://stackexchange.com/legal/terms-of-service" target="_blank">terms of service</a>.</p>
<input name="legalLinksShown" value="1" type="hidden">								</div>
						</form>



						<h2 class="bottom-notice" data-loc="1">
Not the answer you're looking for?							Browse other questions tagged <a href="http://stackoverflow.com/questions/tagged/android" class="post-tag" title="show questions tagged 'android'" rel="tag"><img src="Implementing%20a%20customized%20drawable%20in%20Android_files/tKsDb.png" alt="" class="sponsor-tag-img" height="16" width="18">android</a>  or <a href="http://stackoverflow.com/questions/ask">ask your own question</a>.						</h2>
			</div>
		</div>
				<div id="sidebar" class="show-votes">
						    <div class="module question-stats">
			        <table id="qinfo">
			            <tbody><tr>
			                <td>
			                    <p class="label-key">asked</p>
			                </td>
			                <td style="padding-left: 10px">
			                    <p class="label-key" title="2010-06-03 16:29:27Z"><b>4 years ago</b></p>
			                </td>
			            </tr>
			            <tr>
			                <td>
			                    <p class="label-key">viewed</p>
			                </td>

			                <td style="padding-left: 10px">
			                    <p class="label-key">
			                        <b>12695 times</b>
			                    </p>
			                </td>
			            </tr>
			                <tr>
			                    <td>
			                        <p class="label-key">active</p>
			                    </td>
			                    <td style="padding-left: 10px">
			                        <p class="label-key"><b><a href="http://stackoverflow.com/questions/2967904/implementing-a-customized-drawable-in-android?lastactivity" class="lastactivity-link" title="2015-03-09 12:54:45Z">3 days ago</a></b></p>
			                    </td>
			                </tr>
			        </tbody></table>
			    </div>
						
			<script>
                var ados = ados || {};ados.run = ados.run || [];
                ados.run.push(function() { ados_add_placement(22,8277,"adzerk1149388119",[17,2221]).setZone(45) ; });                    
            </script>
            <div class="everyonelovesstackoverflow" id="adzerk1149388119"><div id="careersadsdoublehigh" style="display:none;"></div><img src="Implementing%20a%20customized%20drawable%20in%20Android_files/i_003.gif" style="position:absolute;" border="0" height="0px" width="0px"></div>  
        <div class="orange looking tagged" id="hireme"><a href="http://careers.stackoverflow.com/jobs?a=33sHe" target="_blank" data-la="33sHe" data-hf="h" class="top"> <span>Looking for a job?</span></a><ul class="jobs"><li><a data-cid="161046" data-la="p0V77QUlOHT" href="http://careers.stackoverflow.com/jobs/74589/agile-tester-mobile-android-m-f-xing-ag" target="_blank" title="Agile Tester - Mobile (Android) (m/f) at XING AG. Click to learn more.">Agile Tester - Mobile (Android) (m/f)<br><div class="company">XING AG</div><div class="location" title="Hamburg, Germany">Hamburg, Germany</div><span class="post-tag">android</span><span class="post-tag">qa</span></a></li><li><a data-cid="166820" data-la="r02dKg69t1U" href="http://careers.stackoverflow.com/jobs/80510/senior-product-manager-woot-strategic-initiatives-amazon" target="_blank" title="Senior Product Manager, Woot Strategic Initiatives at Amazon. Click to learn more.">Senior Product Manager, Woot Strategic Initiatives<br><div class="company">Amazon</div><div class="location" title="Seattle, WA">Seattle, WA</div><span class="post-tag">mobile</span><span class="post-tag">product</span></a></li><li><a data-cid="162133" data-la="pqzW3t9wrN9" href="http://careers.stackoverflow.com/jobs/75823/senior-software-enigneer-android-applications-irobot-corporation" target="_blank" title="Senior Software Enigneer, Android Applications at iRobot Corporation. Click to learn more.">Senior Software Enigneer, Android Applications<br><div class="company">iRobot</div><div class="location" title="Bedford, MA / relocation">Bedford, MA / relocation</div><span class="post-tag">android</span><span class="post-tag">java</span></a></li><li><a data-cid="166950" data-la="r2JOmu4JEMI" href="http://careers.stackoverflow.com/jobs/80640/senior-product-manager-woot-ordering-and-amazon" target="_blank" title="Senior Product Manager, Woot Ordering and Fulfillment at Amazon. Click to learn more.">Senior Product Manager, Woot Ordering and Fulfillment<br><div class="company">Amazon</div><div class="location" title="Seattle, WA / relocation">Seattle, WA / relocation</div><span class="post-tag">e-commerce</span><span class="post-tag">model</span></a></li></ul><img class="impression" src="Implementing%20a%20customized%20drawable%20in%20Android_files/i.gif" style="display:none;"><img class="impression" src="Implementing%20a%20customized%20drawable%20in%20Android_files/p0V77QUlOHT-r02dKg69t1U-pqzW3t9wrN9-r2JOmu4JEMI-33sHe.gif" style="display:none;"></div>
			  
    
            <div class="module sidebar-linked">
	<h4 id="h-linked">Linked</h4>
	<div class="linked" data-tracker="lq=1">
<div class="spacer">
	<a href="http://stackoverflow.com/q/13560526?lq=1" title="Vote score (upvotes - downvotes)">
		<div class="answer-votes answered-accepted default">7</div>
	</a>
	<a href="http://stackoverflow.com/questions/13560526/how-to-implement-dynamic-values-on-menu-item-in-android?lq=1" class="question-hyperlink">How to implement dynamic values on menu item in Android</a>
</div>			</div>
</div>

				<div class="module sidebar-related">
					<h4 id="h-related">Related</h4>
                    <div class="related js-gps-related-questions" data-tracker="rq=1">
                        <div class="spacer js-gps-track">
<a href="http://stackoverflow.com/q/1554099?rq=1" title="Vote score (upvotes - downvotes)">
    <div class="answer-votes extra-large">1690
    </div>
</a><a href="http://stackoverflow.com/questions/1554099/why-is-the-android-emulator-so-slow-how-can-we-speed-up-the-android-emulator?rq=1" class="question-hyperlink">Why is the Android emulator so slow? How can we speed up the Android emulator?</a>
</div>
<div class="spacer js-gps-track">
<a href="http://stackoverflow.com/q/2025282?rq=1" title="Vote score (upvotes - downvotes)">
    <div class="answer-votes answered-accepted extra-large">2262
    </div>
</a><a href="http://stackoverflow.com/questions/2025282/difference-between-px-dp-dip-and-sp-in-android?rq=1" class="question-hyperlink">Difference between px, dp, dip and sp in Android?</a>
</div>
<div class="spacer js-gps-track">
<a href="http://stackoverflow.com/q/2194808?rq=1" title="Vote score (upvotes - downvotes)">
    <div class="answer-votes answered-accepted extra-large">1277
    </div>
</a><a href="http://stackoverflow.com/questions/2194808/debug-certificate-expired-error-in-eclipse-android-plugins?rq=1" class="question-hyperlink">“Debug certificate expired” error in Eclipse Android plugins</a>
</div>
<div class="spacer js-gps-track">
<a href="http://stackoverflow.com/q/6384694?rq=1" title="Vote score (upvotes - downvotes)">
    <div class="answer-votes default">2
    </div>
</a><a href="http://stackoverflow.com/questions/6384694/how-to-share-photo-on-facebook-through-my-android-app?rq=1" class="question-hyperlink">How to share photo on Facebook through my Android App?</a>
</div>
<div class="spacer js-gps-track">
<a href="http://stackoverflow.com/q/13375357?rq=1" title="Vote score (upvotes - downvotes)">
    <div class="answer-votes answered-accepted extra-large">1626
    </div>
</a><a href="http://stackoverflow.com/questions/13375357/proper-use-cases-for-android-usermanager-isuseragoat?rq=1" class="question-hyperlink">Proper use cases for Android UserManager.isUserAGoat()?</a>
</div>
<div class="spacer js-gps-track">
<a href="http://stackoverflow.com/q/15804460?rq=1" title="Vote score (upvotes - downvotes)">
    <div class="answer-votes default">-2
    </div>
</a><a href="http://stackoverflow.com/questions/15804460/android-app-keeps-crashing?rq=1" class="question-hyperlink">Android App Keeps Crashing</a>
</div>
<div class="spacer js-gps-track">
<a href="http://stackoverflow.com/q/18095885?rq=1" title="Vote score (upvotes - downvotes)">
    <div class="answer-votes default">7
    </div>
</a><a href="http://stackoverflow.com/questions/18095885/custom-seekbar-drawable-android?rq=1" class="question-hyperlink">Custom SeekBar Drawable Android</a>
</div>
<div class="spacer js-gps-track">
<a href="http://stackoverflow.com/q/19345333?rq=1" title="Vote score (upvotes - downvotes)">
    <div class="answer-votes default">0
    </div>
</a><a href="http://stackoverflow.com/questions/19345333/android-is-it-possible-to-upload-an-image-on-a-folder-inside-a-server?rq=1" class="question-hyperlink">Android: is it possible to upload an image on a folder inside a server?</a>
</div>
<div class="spacer js-gps-track">
<a href="http://stackoverflow.com/q/28186702?rq=1" title="Vote score (upvotes - downvotes)">
    <div class="answer-votes answered-accepted default">0
    </div>
</a><a href="http://stackoverflow.com/questions/28186702/focus-listener-in-android-tabs?rq=1" class="question-hyperlink">Focus listener in android tabs</a>
</div>
<div class="spacer js-gps-track">
<a href="http://stackoverflow.com/q/28662184?rq=1" title="Vote score (upvotes - downvotes)">
    <div class="answer-votes default">0
    </div>
</a><a href="http://stackoverflow.com/questions/28662184/making-android-custom-drawable?rq=1" class="question-hyperlink">Making android custom drawable</a>
</div>

                    </div>
				</div>
            
<div id="hot-network-questions" class="module">
    <h4>
        <a href="http://stackexchange.com/questions?tab=hot" class="js-gps-track" data-gps-track="posts_hot_network.click({ item_type:1, location:11 })">
            Hot Network Questions
        </a>
    </h4>
    <ul>
            <li>
                <div class="favicon favicon-lifehacks" title="Lifehacks Stack Exchange"></div><a href="http://lifehacks.stackexchange.com/questions/6027/how-to-find-a-hole-in-a-bicycle-tire-tube-quickly" class="js-gps-track" data-gps-track="site.switch({ item_type:11, target_site:593 }); posts_hot_network.click({ item_type:2, location:11 })">
                    How to find a hole in a bicycle tire tube quickly
                </a>

            </li>
            <li>
                <div class="favicon favicon-math" title="Mathematics Stack Exchange"></div><a href="http://math.stackexchange.com/questions/1186784/the-proof-of-divisibility" class="js-gps-track" data-gps-track="site.switch({ item_type:11, target_site:69 }); posts_hot_network.click({ item_type:2, location:11 })">
                    The proof of divisibility
                </a>

            </li>
            <li>
                <div class="favicon favicon-academia" title="Academia Stack Exchange"></div><a href="http://academia.stackexchange.com/questions/41449/is-it-ethical-to-host-ads-on-institute-provided-homepage" class="js-gps-track" data-gps-track="site.switch({ item_type:11, target_site:415 }); posts_hot_network.click({ item_type:2, location:11 })">
                    Is it ethical to host ads on institute provided homepage?
                </a>

            </li>
            <li>
                <div class="favicon favicon-programmers" title="Programmers Stack Exchange"></div><a href="http://programmers.stackexchange.com/questions/275957/is-logging-next-to-an-implementation-a-srp-violation" class="js-gps-track" data-gps-track="site.switch({ item_type:11, target_site:131 }); posts_hot_network.click({ item_type:2, location:11 })">
                    Is logging next to an implementation a SRP violation?
                </a>

            </li>
            <li>
                <div class="favicon favicon-codereview" title="Code Review Stack Exchange"></div><a href="http://codereview.stackexchange.com/questions/83907/filtering-a-list-based-on-a-value" class="js-gps-track" data-gps-track="site.switch({ item_type:11, target_site:196 }); posts_hot_network.click({ item_type:2, location:11 })">
                    Filtering a list based on a value
                </a>

            </li>
            <li style="display: list-item;" class="dno js-hidden">
                <div class="favicon favicon-workplace" title="The Workplace Stack Exchange"></div><a href="http://workplace.stackexchange.com/questions/42638/is-it-appropriate-to-use-myers-briggs-type-indicator-as-selling-point-in-a-perso" class="js-gps-track" data-gps-track="site.switch({ item_type:11, target_site:423 }); posts_hot_network.click({ item_type:2, location:11 })">
                    Is it appropriate to use Myers-Briggs Type Indicator as selling point in a personal statement?
                </a>

            </li>
            <li style="display: list-item;" class="dno js-hidden">
                <div class="favicon favicon-tex" title="TeX - LaTeX Stack Exchange"></div><a href="http://tex.stackexchange.com/questions/232713/warning-using-typearea-a5-bcor-8mm-div-calc" class="js-gps-track" data-gps-track="site.switch({ item_type:11, target_site:85 }); posts_hot_network.click({ item_type:2, location:11 })">
                    Warning, using: typearea, a5, BCOR=8mm, DIV=calc
                </a>

            </li>
            <li style="display: list-item;" class="dno js-hidden">
                <div class="favicon favicon-mathoverflow" title="MathOverflow"></div><a href="http://mathoverflow.net/questions/199767/choice-of-fibrations-is-like-a-choice-of-a-basis-of-a-module" class="js-gps-track" data-gps-track="site.switch({ item_type:11, target_site:504 }); posts_hot_network.click({ item_type:2, location:11 })">
                    Choice of fibrations is like a choice of a basis of a module
                </a>

            </li>
            <li style="display: list-item;" class="dno js-hidden">
                <div class="favicon favicon-english" title="English Language &amp; Usage Stack Exchange"></div><a href="http://english.stackexchange.com/questions/232979/can-i-use-one-word-to-say-common-human-behaviour" class="js-gps-track" data-gps-track="site.switch({ item_type:11, target_site:97 }); posts_hot_network.click({ item_type:2, location:11 })">
                    Can I use one word to say- 'common human behaviour'
                </a>

            </li>
            <li style="display: list-item;" class="dno js-hidden">
                <div class="favicon favicon-travel" title="Travel Stack Exchange"></div><a href="http://travel.stackexchange.com/questions/44519/what-currencies-can-i-use-in-istanbul" class="js-gps-track" data-gps-track="site.switch({ item_type:11, target_site:273 }); posts_hot_network.click({ item_type:2, location:11 })">
                    What currencies can I use in Istanbul?
                </a>

            </li>
            <li style="display: list-item;" class="dno js-hidden">
                <div class="favicon favicon-salesforce" title="Salesforce Stack Exchange"></div><a href="http://salesforce.stackexchange.com/questions/69047/formula-not-evaluating-null-picklist-value-as-expected" class="js-gps-track" data-gps-track="site.switch({ item_type:11, target_site:459 }); posts_hot_network.click({ item_type:2, location:11 })">
                    Formula not evaluating null picklist value as expected
                </a>

            </li>
            <li style="display: list-item;" class="dno js-hidden">
                <div class="favicon favicon-worldbuilding" title="Worldbuilding Stack Exchange"></div><a href="http://worldbuilding.stackexchange.com/questions/11762/making-part-of-the-planet-completely-inaccessible" class="js-gps-track" data-gps-track="site.switch({ item_type:11, target_site:579 }); posts_hot_network.click({ item_type:2, location:11 })">
                    Making Part of the Planet Completely Inaccessible
                </a>

            </li>
            <li style="display: list-item;" class="dno js-hidden">
                <div class="favicon favicon-cs" title="Computer Science Stack Exchange"></div><a href="http://cs.stackexchange.com/questions/40355/checking-whether-all-integers-appear-exactly-once" class="js-gps-track" data-gps-track="site.switch({ item_type:11, target_site:419 }); posts_hot_network.click({ item_type:2, location:11 })">
                    Checking whether all integers appear exactly once
                </a>

            </li>
            <li style="display: list-item;" class="dno js-hidden">
                <div class="favicon favicon-aviation" title="Aviation Stack Exchange"></div><a href="http://aviation.stackexchange.com/questions/13132/why-do-planes-always-land-on-rear-wheels-instead-of-the-nose-wheels" class="js-gps-track" data-gps-track="site.switch({ item_type:11, target_site:528 }); posts_hot_network.click({ item_type:2, location:11 })">
                    Why do planes always land on rear wheels instead of the nose wheels?
                </a>

            </li>
            <li style="display: list-item;" class="dno js-hidden">
                <div class="favicon favicon-gis" title="Geographic Information Systems Stack Exchange"></div><a href="http://gis.stackexchange.com/questions/138593/google-earth-alternatives" class="js-gps-track" data-gps-track="site.switch({ item_type:11, target_site:79 }); posts_hot_network.click({ item_type:2, location:11 })">
                    Google Earth alternatives?
                </a>

            </li>
            <li style="display: list-item;" class="dno js-hidden">
                <div class="favicon favicon-money" title="Personal Finance &amp; Money Stack Exchange"></div><a href="http://money.stackexchange.com/questions/45419/am-i-obligated-to-file-through-a-tax-preparer-after-an-unsatisfactory-consultati" class="js-gps-track" data-gps-track="site.switch({ item_type:11, target_site:93 }); posts_hot_network.click({ item_type:2, location:11 })">
                    Am I obligated to file through a tax preparer after an unsatisfactory consultation?
                </a>

            </li>
            <li style="display: list-item;" class="dno js-hidden">
                <div class="favicon favicon-vi" title="Vi and Vim Stack Exchange"></div><a href="http://vi.stackexchange.com/questions/2505/youcompleteme-in-non-code-files-yields-user-defined-completion-unp-patte" class="js-gps-track" data-gps-track="site.switch({ item_type:11, target_site:599 }); posts_hot_network.click({ item_type:2, location:11 })">
                    YouCompleteMe in non-code files yields -- User defined completion (^U^N^P) Pattern not found
                </a>

            </li>
            <li style="display: list-item;" class="dno js-hidden">
                <div class="favicon favicon-italian" title="Italian Language Stack Exchange"></div><a href="http://italian.stackexchange.com/questions/5231/difference-between-vecchio-and-anziano" class="js-gps-track" data-gps-track="site.switch({ item_type:11, target_site:524 }); posts_hot_network.click({ item_type:2, location:11 })">
                    Difference between "vecchio" and "anziano"
                </a>

            </li>
            <li style="display: list-item;" class="dno js-hidden">
                <div class="favicon favicon-gaming" title="Arqade"></div><a href="http://gaming.stackexchange.com/questions/209518/enchanting-items" class="js-gps-track" data-gps-track="site.switch({ item_type:11, target_site:41 }); posts_hot_network.click({ item_type:2, location:11 })">
                    Enchanting Items
                </a>

            </li>
            <li style="display: list-item;" class="dno js-hidden">
                <div class="favicon favicon-puzzling" title="Puzzling Stack Exchange"></div><a href="http://puzzling.stackexchange.com/questions/10121/find-the-odd-one-out" class="js-gps-track" data-gps-track="site.switch({ item_type:11, target_site:559 }); posts_hot_network.click({ item_type:2, location:11 })">
                    Find the odd one out
                </a>

            </li>
            <li style="display: list-item;" class="dno js-hidden">
                <div class="favicon favicon-codegolf" title="Programming Puzzles &amp; Code Golf Stack Exchange"></div><a href="http://codegolf.stackexchange.com/questions/47638/area-of-a-self-intersecting-polygon" class="js-gps-track" data-gps-track="site.switch({ item_type:11, target_site:200 }); posts_hot_network.click({ item_type:2, location:11 })">
                    Area of a Self-Intersecting Polygon
                </a>

            </li>
            <li style="display: list-item;" class="dno js-hidden">
                <div class="favicon favicon-rpg" title="Role-playing Games Stack Exchange"></div><a href="http://rpg.stackexchange.com/questions/57890/could-vampires-use-touchscreen-devices-iphone-etc" class="js-gps-track" data-gps-track="site.switch({ item_type:11, target_site:122 }); posts_hot_network.click({ item_type:2, location:11 })">
                    Could Vampires use touchscreen devices (iPhone, etc)?
                </a>

            </li>
            <li style="display: list-item;" class="dno js-hidden">
                <div class="favicon favicon-math" title="Mathematics Stack Exchange"></div><a href="http://math.stackexchange.com/questions/1186912/2005-putnam-b1-find-a-polynomial" class="js-gps-track" data-gps-track="site.switch({ item_type:11, target_site:69 }); posts_hot_network.click({ item_type:2, location:11 })">
                    2005 Putnam B1: Find a Polynomial
                </a>

            </li>
            <li style="display: list-item;" class="dno js-hidden">
                <div class="favicon favicon-rpg" title="Role-playing Games Stack Exchange"></div><a href="http://rpg.stackexchange.com/questions/57906/making-players-more-interested-in-lore-world" class="js-gps-track" data-gps-track="site.switch({ item_type:11, target_site:122 }); posts_hot_network.click({ item_type:2, location:11 })">
                    Making players more interested in lore/world?
                </a>

            </li>
    </ul>

        
</div>
		</div>
	
<div id="feed-link">
    <div id="feed-link-text">
        <a href="http://stackoverflow.com/feeds/question/2967904" title="feed of this question and its answers">
            <span class="feed-icon"></span>question feed
        </a>
    </div>
</div>	<script>
StackExchange.ready(function(){$.get('/posts/2967904/ivc/436c');});
</script>
<noscript>
    <div><img src="/posts/2967904/ivc/436c" class="dno" alt="" width="0" height="0"></div>
</noscript><div style="display:none" id="prettify-lang">default</div></div>



        </div>
    </div>
    <div id="footer" class="categories">
        <div class="footerwrap">
            <div id="footer-menu">
                <div class="top-footer-links">
                        <a href="http://stackoverflow.com/tour">tour</a>
                    <a href="http://stackoverflow.com/help">help</a>
                    <a href="http://blog.stackoverflow.com/?blb=1">blog</a>
                        <a href="http://chat.stackoverflow.com/">chat</a>
                    <a href="http://data.stackexchange.com/">data</a>
                    <a href="http://stackexchange.com/legal">legal</a>
                    <a href="http://stackexchange.com/legal/privacy-policy">privacy policy</a>
                    <a href="http://stackexchange.com/work-here">work here</a>
                    <a href="http://stackexchange.com/mediakit">advertising info</a>

                    <a onclick='StackExchange.switchMobile("on")'>mobile</a>
                    <b><a href="http://stackoverflow.com/contact">contact us</a></b>
                        <b><a href="http://meta.stackoverflow.com/">feedback</a></b>
                    
                </div>
                <div id="footer-sites">
                    <table>
    <tbody><tr>
            <th colspan="3">
                Technology
            </th>
            <th>
                Life / Arts
            </th>
            <th>
                Culture / Recreation
            </th>
            <th>
                Science
            </th>
            <th>
                Other
            </th>
    </tr>
    <tr>
            <td>
                <ol>
                        <li><a href="http://stackoverflow.com/" title="professional and enthusiast programmers">Stack Overflow</a></li>
                        <li><a href="http://serverfault.com/" title="system and network administrators">Server Fault</a></li>
                        <li><a href="http://superuser.com/" title="computer enthusiasts and power users">Super User</a></li>
                        <li><a href="http://webapps.stackexchange.com/" title="power users of web applications">Web Applications</a></li>
                        <li><a href="http://askubuntu.com/" title="Ubuntu users and developers">Ask Ubuntu</a></li>
                        <li><a href="http://webmasters.stackexchange.com/" title="pro webmasters">Webmasters</a></li>
                        <li><a href="http://gamedev.stackexchange.com/" title="professional and independent game developers">Game Development</a></li>
                        <li><a href="http://tex.stackexchange.com/" title="users of TeX, LaTeX, ConTeXt, and related typesetting systems">TeX - LaTeX</a></li>
                            </ol></td><td><ol>
                        <li><a href="http://programmers.stackexchange.com/" title="professional programmers interested in conceptual questions about software development">Programmers</a></li>
                        <li><a href="http://unix.stackexchange.com/" title="users of Linux, FreeBSD and other Un*x-like operating systems.">Unix &amp; Linux</a></li>
                        <li><a href="http://apple.stackexchange.com/" title="power users of Apple hardware and software">Ask Different (Apple)</a></li>
                        <li><a href="http://wordpress.stackexchange.com/" title="WordPress developers and administrators">WordPress Development</a></li>
                        <li><a href="http://gis.stackexchange.com/" title="cartographers, geographers and GIS professionals">Geographic Information Systems</a></li>
                        <li><a href="http://electronics.stackexchange.com/" title="electronics and electrical engineering professionals, students, and enthusiasts">Electrical Engineering</a></li>
                        <li><a href="http://android.stackexchange.com/" title="enthusiasts and power users of the Android operating system">Android Enthusiasts</a></li>
                        <li><a href="http://security.stackexchange.com/" title="Information security professionals">Information Security</a></li>
                            </ol></td><td><ol>
                        <li><a href="http://dba.stackexchange.com/" title="database professionals who wish to improve their database skills and learn from others in the community">Database Administrators</a></li>
                        <li><a href="http://drupal.stackexchange.com/" title="Drupal developers and administrators">Drupal Answers</a></li>
                        <li><a href="http://sharepoint.stackexchange.com/" title="SharePoint enthusiasts">SharePoint</a></li>
                        <li><a href="http://ux.stackexchange.com/" title="user experience researchers and experts">User Experience</a></li>
                        <li><a href="http://mathematica.stackexchange.com/" title="users of Mathematica">Mathematica</a></li>
                        <li><a href="http://salesforce.stackexchange.com/" title="Salesforce administrators, implementation experts, developers and anybody in-between">Salesforce</a></li>
                    
                        <li>
                            <a href="http://stackexchange.com/sites#technology" class="more">
                                more (14)
                            </a>
                        </li>
                </ol>
            </td>
            <td>
                <ol>
                        <li><a href="http://photo.stackexchange.com/" title="professional, enthusiast and amateur photographers">Photography</a></li>
                        <li><a href="http://scifi.stackexchange.com/" title="science fiction and fantasy enthusiasts">Science Fiction &amp; Fantasy</a></li>
                        <li><a href="http://graphicdesign.stackexchange.com/" title="Graphic Design professionals, students, and enthusiasts">Graphic Design</a></li>
                        <li><a href="http://cooking.stackexchange.com/" title="professional and amateur chefs">Seasoned Advice (cooking)</a></li>
                        <li><a href="http://diy.stackexchange.com/" title="contractors and serious DIYers">Home Improvement</a></li>
                        <li><a href="http://money.stackexchange.com/" title="people who want to be financially literate">Personal Finance &amp; Money</a></li>
                        <li><a href="http://academia.stackexchange.com/" title="academics and those enrolled in higher education">Academia</a></li>
                    
                        <li>
                            <a href="http://stackexchange.com/sites#lifearts" class="more">
                                more (10)
                            </a>
                        </li>
                </ol>
            </td>
            <td>
                <ol>
                        <li><a href="http://english.stackexchange.com/" title="linguists, etymologists, and serious English language enthusiasts">English Language &amp; Usage</a></li>
                        <li><a href="http://skeptics.stackexchange.com/" title="scientific skepticism">Skeptics</a></li>
                        <li><a href="http://judaism.stackexchange.com/" title="those who base their lives on Jewish law and tradition and anyone interested in learning more">Mi Yodeya (Judaism)</a></li>
                        <li><a href="http://travel.stackexchange.com/" title="road warriors and seasoned travelers">Travel</a></li>
                        <li><a href="http://christianity.stackexchange.com/" title="committed Christians, experts in Christianity and those interested in learning more">Christianity</a></li>
                        <li><a href="http://gaming.stackexchange.com/" title="passionate videogamers on all platforms">Arqade (gaming)</a></li>
                        <li><a href="http://bicycles.stackexchange.com/" title="people who build and repair bicycles, people who train cycling, or commute on bicycles">Bicycles</a></li>
                        <li><a href="http://rpg.stackexchange.com/" title="gamemasters and players of tabletop, paper-and-pencil role-playing games">Role-playing Games</a></li>
                    
                        <li>
                            <a href="http://stackexchange.com/sites#culturerecreation" class="more">
                                more (21)
                            </a>
                        </li>
                </ol>
            </td>
            <td>
                <ol>
                        <li><a href="http://math.stackexchange.com/" title="people studying math at any level and professionals in related fields">Mathematics</a></li>
                        <li><a href="http://stats.stackexchange.com/" title="people interested in statistics, machine learning, data analysis, data mining, and data visualization">Cross Validated (stats)</a></li>
                        <li><a href="http://cstheory.stackexchange.com/" title="theoretical computer scientists and researchers in related fields">Theoretical Computer Science</a></li>
                        <li><a href="http://physics.stackexchange.com/" title="active researchers, academics and students of physics">Physics</a></li>
                        <li><a href="http://mathoverflow.net/" title="professional mathematicians">MathOverflow</a></li>
                    
                        <li>
                            <a href="http://stackexchange.com/sites#science" class="more">
                                more (7)
                            </a>
                        </li>
                </ol>
            </td>
            <td>
                <ol>
                        <li><a href="http://stackapps.com/" title="apps, scripts, and development with the Stack Exchange API">Stack Apps</a></li>
                        <li><a href="http://meta.stackexchange.com/" title="meta-discussion of the Stack Exchange family of Q&amp;A websites">Meta Stack Exchange</a></li>
                        <li><a href="http://area51.stackexchange.com/" title="proposing new sites in the Stack Exchange network">Area 51</a></li>
                        <li><a href="http://careers.stackoverflow.com/">Stack Overflow Careers</a></li>
                    
                </ol>
            </td>
    </tr>
</tbody></table>
                </div>
            </div>

            <div id="copyright">
                site design / logo © 2015 stack exchange inc; user contributions licensed under <a href="http://creativecommons.org/licenses/by-sa/3.0/" rel="license">cc by-sa 3.0</a> 
                with <a href="http://blog.stackoverflow.com/2009/06/attribution-required/" rel="license">attribution required</a>
            </div>
            <div id="svnrev">
                rev 2015.3.12.2382
            </div>
            
        </div>
    </div>
    <noscript>
        <div id="noscript-warning">Stack Overflow works best with JavaScript enabled<img src="http://pixel.quantserve.com/pixel/p-c1rF4kxgLUzNc.gif" alt="" class="dno"></div>
    </noscript>
<script>var p = "http", d = "static"; if (document.location.protocol == "https:") { p += "s"; d = "engine"; } var z = document.createElement("script"); z.type = "text/javascript"; z.async = true; z.src = p + "://" + d + ".adzerk.net/ados.js"; var s = document.getElementsByTagName("script")[0]; s.parentNode.insertBefore(z, s);</script>
<script>
    var ados = ados || {};
    ados.run = ados.run || [];
    ados.run.push(function () { ados_setKeywords('android');; ados_load(); });         
</script>

    <script>
        (function (i, s, o, g, r, a, m) {
            i['GoogleAnalyticsObject'] = r; i[r] = i[r] || function () { (i[r].q = i[r].q || []).push(arguments) }, i[r].l = 1 * new Date(); a = s.createElement(o),
            m = s.getElementsByTagName(o)[0]; a.async = 1; a.src = g; m.parentNode.insertBefore(a, m);
        })(window, document, 'script', '//www.google-analytics.com/analytics.js', 'ga');
        ga('create', 'UA-5620270-1');        
        
        ga('set', 'dimension2', '|android|');         
        ga('send', 'pageview');
        var _qevents = _qevents || [],
            _comscore = _comscore || [];
        (function () {
            var ssl='https:'==document.location.protocol,
                s=document.getElementsByTagName('script')[0],
                qc=document.createElement('script');
            qc.async=true;
            qc.src=(ssl?'https://secure':'http://edge')+'.quantserve.com/quant.js';
            s.parentNode.insertBefore(qc, s);
            var sc=document.createElement('script');
            sc.async=true;
            sc.src=(ssl?'https://sb':'http://b') + '.scorecardresearch.com/beacon.js';
            s.parentNode.insertBefore(sc, s);
        })();
        _comscore.push({ c1: "2", c2: "17440561" });
        _qevents.push({ qacct: "p-c1rF4kxgLUzNc" });
    </script>        
    
    
<script src="Implementing%20a%20customized%20drawable%20in%20Android_files/p" type="text/javascript"></script></body></html>